//
//  NSString+Category.h
//  Community
//
//  Created by xtjun on 2023/7/4.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSString (Category)

@property (nullable, nonatomic, readonly) NSString *tj_documentsPath;
@property (nullable, nonatomic, readonly) NSString *tj_tempPath;
@property (nullable, nonatomic, readonly) NSString *tj_cachePath;


@property (nullable, nonatomic, readonly) NSString *tj_imageCachePath;
@property (nullable, nonatomic, readonly) NSString *tj_downloadCachePath;
@property (nullable, nonatomic, readonly) NSString *tj_tmpCachePath;
 
 
- (NSString *)localizedString;
- (nonnull NSString *)replacingEmptyString;

- (NSAttributedString *)titleMargin:(CGFloat)magrin font:(UIFont *)font alignment:(NSTextAlignment)alignment;
- (NSAttributedString *)titleMargin:(CGFloat)magrin alignment:(NSTextAlignment)alignment;

- (NSAttributedString *)titleMargin:(CGFloat)magrin paragraphSpacing:(CGFloat)paragraphSpacing firstLineHeadIndent:(CGFloat)firstLineHeadIndent alignment:(NSTextAlignment)alignment;
- (NSAttributedString *)titleMargin:(CGFloat)magrin paragraphSpacing:(CGFloat)paragraphSpacing alignment:(NSTextAlignment)alignment;
- (nonnull NSAttributedString *)attributedString:(NSRange)range rangeFont:(UIFont *)rangeFont rangeColor:(nonnull UIColor *)rangeColor font:(UIFont *)font color:(nonnull UIColor *)color;

- (CGSize)getStringSizeWithWidth:(CGFloat)width fontSize:(CGFloat)fontSize;
- (CGSize)getStringSizeWithWidth:(CGFloat)width font:(UIFont *)font;

+ (NSString *)dateStringWithDateFormat:(NSDateFormatter *)dateFormat timeInterval:(NSTimeInterval)timeInterval;

+ (float)floatWithdecimalNumber:(double)num;

+ (double)doubleWithdecimalNumber:(double)num;

+ (NSString *)stringWithDecimalNumber:(double)num;

+ (NSDecimalNumber *)decimalNumber:(double)num;
 

- (nonnull NSAttributedString *)attributedStringWithRange:(NSRange)range foregroundFont:(UIFont *)foregroundFont backgroundFont:(UIFont *)backgroundFont foregroundcolor:(nonnull UIColor *)foregroundcolor backgroundColor:(nonnull UIColor *)backgroundColor;

- (nonnull NSAttributedString *)attributedStringWithRange:(NSRange)range rangeFont:(UIFont *)rangeFont rangeColor:(nonnull UIColor *)rangeColor font:(UIFont *)font color:(nonnull UIColor *)color;

- (nonnull NSMutableAttributedString *)attributedStringWithRangeString:(nullable NSString *)rangeString rangeColor:(nonnull UIColor *)rangeColor color:(nonnull UIColor *)color;

- (nonnull NSMutableAttributedString *)attributedStringWithRangeStrings:(nullable NSArray <NSString *>*)rangeStrings rangeColor:(nonnull UIColor *)rangeColor color:(nonnull UIColor *)color;

- (nonnull NSMutableAttributedString *)attributedStringWithRangeString:(nullable NSString *)rangeString rangeColor:(nonnull UIColor *)rangeColor color:(nonnull UIColor *)color titleMargin:(CGFloat)magrin;

- (BOOL)isEqualToString:(NSString *)string options:(NSStringCompareOptions)mask;

- (NSString *)firstPinYin;
- (NSString *)firstChar;
- (NSString *)lastChar;
- (NSString *)removeLastChar;
- (NSString *)removefirstChar;
- (NSString *)removeFirstLastEmptyString;
 
- (NSString *)encodeUrl;
- (NSString *)decodeUrl;

- (NSURL *)URL;
- (NSString *)md5;
- (NSString *)sha1;

@end

NS_ASSUME_NONNULL_END
